# -*- coding:utf-8 -*-
import pygame

class Ship ():
    """"""
    def __init__(self, alien_settings, screen):
        self.screen = screen

        self.image = pygame.image.load("./image/ship.bmp")
        self.image_rect = self.image.get_rect()
        self.screen_rect = screen.get_rect()
        print(str(screen.get_rect()) + '\n')
        self.image_rect.centerx = self.screen_rect.centerx
        self.image_rect.bottom = self.screen_rect.bottom
        self.moving_right = False
        self.moving_left = False
        self.alien_settings = alien_settings
        self.center = float(self.image_rect.centerx)

    def blitme(self):
        self.screen.blit(self.image, self.image_rect)

    def update (self):
        """
        根据移动标志调整物体的位置
        """
        if self.moving_right:
            # self.image_rect.centerx += 2
            # self.image_rect.centerx += float(self.alien_settings.ship_speed_factor)
            if self.image_rect.right < self.screen_rect.right:
                self.center += float(self.alien_settings.ship_speed_factor)
        elif self.moving_left:
            if self.image_rect.left > 0:
                self.center -= self.alien_settings.ship_speed_factor
            else:
                self.image_rect.centerx = 0

        self.image_rect.centerx = self.center